package com.ruoyi.project.operationalsystem.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.operationalsystem.domain.VDeclare;
import com.ruoyi.project.operationalsystem.service.IVDeclareService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 故障申报Controller
 * 
 * @author ruoyi
 * @date 2020-05-09
 */
@RestController
@RequestMapping("/operationalsystem/declare")
public class VDeclareController extends BaseController
{
    @Autowired
    private IVDeclareService vDeclareService;

    /**
     * 查询故障申报列表
     */
    @PreAuthorize("@ss.hasPermi('operationalsystem:declare:list')")
    @GetMapping("/list")
    public TableDataInfo list(VDeclare vDeclare)
    {
        startPage();
        List<VDeclare> list = vDeclareService.selectVDeclareList(vDeclare);
        return getDataTable(list);
    }

    /**
     * 导出故障申报列表
     */
    @PreAuthorize("@ss.hasPermi('operationalsystem:declare:export')")
    @Log(title = "故障申报", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(VDeclare vDeclare)
    {
        List<VDeclare> list = vDeclareService.selectVDeclareList(vDeclare);
        ExcelUtil<VDeclare> util = new ExcelUtil<VDeclare>(VDeclare.class);
        return util.exportExcel(list, "declare");
    }

    /**
     * 获取故障申报详细信息
     */
    @PreAuthorize("@ss.hasPermi('operationalsystem:declare:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(vDeclareService.selectVDeclareById(id));
    }

    /**
     * 新增故障申报
     */
    @PreAuthorize("@ss.hasPermi('operationalsystem:declare:add')")
    @Log(title = "故障申报", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody VDeclare vDeclare)
    {
        return toAjax(vDeclareService.insertVDeclare(vDeclare));
    }

    /**
     * 修改故障申报
     */
    @PreAuthorize("@ss.hasPermi('operationalsystem:declare:edit')")
    @Log(title = "故障申报", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody VDeclare vDeclare)
    {
        return toAjax(vDeclareService.updateVDeclare(vDeclare));
    }

    /**
     * 删除故障申报
     */
    @PreAuthorize("@ss.hasPermi('operationalsystem:declare:remove')")
    @Log(title = "故障申报", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(vDeclareService.deleteVDeclareByIds(ids));
    }
}
